Total Complexity | 6 |
Total Lines | 27 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import fs from 'fs-extra'; |
||
5 | export default class JSONReporter extends Base { |
||
6 | _generate(groups, map) { |
||
7 | const injected = Object.keys(groups) |
||
8 | .map(groupName => ({ |
||
9 | group : groupName, |
||
10 | titles : Object.keys(groups[groupName]) |
||
11 | .map(title => ({ |
||
12 | name : title, |
||
13 | actions : groups[groupName][title] |
||
14 | .map(id => map.get(id)) |
||
15 | .map(action => ({ |
||
16 | request : action.request, |
||
17 | response : action.response |
||
18 | })) |
||
19 | })) |
||
20 | })); |
||
21 | |||
22 | return JSON.stringify(injected, null, DEFAULT_JSON_OFFSET); |
||
23 | } |
||
24 | |||
25 | async write(actions) { |
||
26 | const { groups, map } = this._build(actions); |
||
27 | const content = this._generate(groups, map); |
||
28 | |||
29 | await fs.writeFile(this.file, content); |
||
30 | } |
||
31 | } |
||
32 |